% this script copies the original data files to the anonymous ones
% ----------------------------------------------------------------
ff = {'bryan'  ; 'randy' ; 'edmay' ;  'hoss'     ; 'gene'    ; 'elaine' ; 'joe'  ; 'curt';  
      'richard'; 'loch'  ; 'gary'  ; 'johnastin' ; 'francis' ; 'carol'  ; 'james'; 'zoran' };
subjectcodes = { 'c1' 'c2' 'c3' 'c4' 'c5' 'c6' 'c7' 'c8' 'nd1' 'nd2' 'nd3' 'nd4' 'nd5' 'nd6' 'nd7' 'nd8' };

for index = 1:length(ff) 
    filename = fullfile(ff{index}, [ ff{index} '.raw' ]);
    if exist(filename)
         filenameIn = fullfile(ff{index}, [ ff{index} '.raw' ]);
    else
         filenameIn = { fullfile(ff{index}, [ ff{index} '001.raw' ]) ...
                        fullfile(ff{index}, [ ff{index} '002.raw' ]) ...
                        fullfile(ff{index}, [ ff{index} '003.raw' ]) ...
                        fullfile(ff{index}, [ ff{index} '004.raw' ]) ...
                        fullfile(ff{index}, [ ff{index} '005.raw' ]) };
    end;
    if exist(subjectcodes{index}) == 0
        mkdir(subjectcodes{index})
    end;
    
    % copy files
    % ----------
    if isstr(filenameIn)
        copyfile(filenameIn, fullfile(subjectcodes{index}, [ subjectcodes{index} '.raw' ]));
    else
        for fInd = 1:length(filenameIn)
            if exist(filenameIn{fInd})
                copyfile(filenameIn{fInd}, fullfile(subjectcodes{index}, sprintf('%s_%3.3d.raw', subjectcodes{index}, fInd)));
            end;
        end;
    end;
end;
